﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Input;

namespace MT.ControlLibrary.Controls
{
    public class CustomTextBox:TextBox
    {
        //定义Hint作为依赖属性
        public static readonly DependencyProperty HintProperty = DependencyProperty.Register("Hint", typeof(string), typeof(CustomTextBox), new PropertyMetadata(string.Empty, OnPropertyChanged));
        public string Hint
        {
            get { return (string)GetValue(HintProperty); }
            set { SetValue(HintProperty, value); }
        }

        //定义圆角属性
        public static readonly DependencyProperty CornerRadiusProperty = DependencyProperty.Register("CornerRadius", typeof(CornerRadius), typeof(CustomTextBox), new FrameworkPropertyMetadata(OnPropertyChanged));
        public CornerRadius CornerRadius
        {
            get { return (CornerRadius)GetValue(CornerRadiusProperty); }
            set { SetValue(CornerRadiusProperty, value); }
        }

        /// <summary>
        /// The command property
        /// </summary>
        public static readonly DependencyProperty BtnDeleteCommandProperty = DependencyProperty.Register("BtnDeleteCommand", typeof(ICommand), typeof(CustomTextBox), new PropertyMetadata(default(ICommand)));
        public ICommand BtnDeleteCommand
        {
            get { return (ICommand)GetValue(BtnDeleteCommandProperty); }
            set { SetValue(BtnDeleteCommandProperty, value); }
        }

        static CustomTextBox()
        {
            DefaultStyleKeyProperty.OverrideMetadata(typeof(CustomTextBox), new FrameworkPropertyMetadata(typeof(CustomTextBox)));
        }

        private static void OnPropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
        {
            d.SetValue(e.Property, e.NewValue);
        }
    }
}
